package view.component.weapon.slash_axe
{
	import enums.main.UISize;
	
	import feathers.controls.Button;
	import feathers.controls.Label;
	import feathers.controls.ScrollContainer;
	import feathers.controls.TabBar;
	import feathers.data.ListCollection;
	
	import util.FG2FUGenerator;
	
	import view.component.weapon.BaseShortWeaponSearchView;
	import view.event.weapon.WeaponSearchViewEvent;
	
	
	/**
	 * 斩击斧搜索界面
	 * @author £iang
	 * 
	 */	
	public class SlashAxeSearchView extends BaseShortWeaponSearchView
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 装着瓶标题 */
		public var bottleTitle:Label;
		/** 装着瓶选项 */
		public var bottleTabBar:TabBar;
		/** 装着瓶选项滚动条容器 */
		public var bottleTabSC:ScrollContainer;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		override protected function initialize():void
		{
			super.initialize();
			
			var labelVec:Vector.<String>;
			var dataProvider1:ListCollection = new ListCollection( [] );
			var len:int;
			var i:int;
			var obj:Object;
			
			bottleTitle = new Label();
			bottleTitle.text = "着瓶：";
			mainSC.addChild( bottleTitle );
			
			labelVec = new Vector.<String>();
			labelVec.push( "全部", "强击", "强属", "灭龙", "毒", "麻痹", "灭气" );
			bottleTabBar = new TabBar();
			bottleTabBar.gap = 15 * this.dpiScale;
			len = labelVec.length;
			
			for ( i = 0; i < len; i ++ )
			{
				obj = new Object();
				obj.label = labelVec[ i ];
				dataProvider1.push( obj );
			}
			
			bottleTabBar.dataProvider = dataProvider1;
			bottleTabBar.tabFactory = mainTabFactory;
			bottleTabSC = new ScrollContainer();
			mainSC.addChild( bottleTabSC );
			bottleTabSC.addChild( bottleTabBar );
			
			obj = new Object();
			obj.label = "着瓶";
			
			sortTabBar.dataProvider.push( obj );
		}
		
		override protected function draw():void
		{
			super.draw();
			bottleTitle.x = 20 * this.dpiScale;
			bottleTitle.y = 360 * this.dpiScale;
			bottleTabSC.x =  110 * this.dpiScale;
			bottleTabSC.y =  360 * this.dpiScale;
			bottleTabSC.width = UISize.MAIN_W - 130 * this.dpiScale;
		}
		
		override public function dispatchSearchEvent():void
		{
			var weaponSearchEvent:WeaponSearchViewEvent = 
				new WeaponSearchViewEvent( WeaponSearchViewEvent.SEARCH );
			
			weaponSearchEvent.rank = levelTabBar.selectedIndex + 1;
			weaponSearchEvent.awakeType = awakenTabBar.selectedIndex;
			weaponSearchEvent.attribute = attributeTabBar.selectedIndex - 1;
			weaponSearchEvent.add = addSharpTabBar.selectedIndex;
			weaponSearchEvent.blade = sharpTabBar.selectedIndex;
			weaponSearchEvent.slot = slotTabBar.selectedIndex - 1;
			weaponSearchEvent.sort = sortTabBar.selectedIndex;
			weaponSearchEvent.axeBottle = bottleTabBar.selectedIndex - 1;
			dispatchCommonEvent( weaponSearchEvent );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			var i:int;
			var button:Button;
			
			bottleTitle.dispose(); bottleTitle = null;
			
			for ( i = 0; i < bottleTabBar.numChildren; i ++ )
			{
				if ( bottleTabBar.getChildAt( i ) is Button )
				{
					button = bottleTabBar.getChildAt( i ) as Button;
					button.dispose();
					FG2FUGenerator.deepDisposeButtonComp( button );
					button = null;
				}
			}
			
			bottleTabSC.dispose(); bottleTabSC = null;
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function SlashAxeSearchView()
		{
			super();
			insertOffset = 60;
			searchAreaH = 540;
			weaponType = "slash_axe";
		}
	}
}